#ifndef		GUI__Button_h
#define		GUI__Button_h

#include	"Control.h"
#include	"CallBack.h"
#include	<OpenGL/Color.h>
#include	<Font/Font.h>
#include	<Sound/SoundSystem.h>
#include	<Textures/Texture.h>
#include	<string>

enum ButtonState
{
	bsNormal,
	bsHover,
	bsDown
};

class Button : public Control
{
public:
	Button(
		Config * config,
		Window * window,
		Mouse * mouse,
		Font * font,
		SoundSystem * soundSystem,
		const std::string & text,
		unsigned int textSize,
		const Vector2i & position,
		const Vector2i & size,
		ICallBack * mouseDown = 0,
		ICallBack * mouseHold = 0,
		ICallBack * mouseUp = 0,
		ICallBack * mouseClick = 0,
		bool visible = true,
		const Vector2i & windowSize = Vector2i(800, 600)
		);
	virtual ~Button();
	virtual void message(int id, void * parameter);
	virtual void updateAnimation(double delay);
	virtual void render() const;
public:
	const std::string & getText() const;
	unsigned int getTextSize() const;
	ButtonState getState() const;
	const ICallBack * getMouseDown() const;
	const ICallBack * getMouseHold() const;
	const ICallBack * getMouseUp() const;
	const ICallBack * getMouseClick() const;
	void setText(const std::string & text);
	void setTextSize(unsigned int textSize);
	void setMouseDown(ICallBack * mouseDown);
	void setMouseHold(ICallBack * mouseHold);
	void setMouseUp(ICallBack * mouseUp);
	void setMouseClick(ICallBack * mouseClick);
	void call(ICallBack * callBack);
private:
	Font * m_font;
	std::string m_text;
	unsigned int m_textSize;
	ButtonState m_state;
	ICallBack * m_mouseDown;
	ICallBack * m_mouseHold;
	ICallBack * m_mouseUp;
	ICallBack * m_mouseClick;
private:
	struct SharedData
	{
		static SharedData * m_ptr;
		unsigned int m_buttonCount;
		Vector2f m_buttonNormalTexPosition;
		Vector2f m_buttonHoverTexPosition;
		Vector2f m_buttonDownTexPosition;
		Vector2f m_buttonTexSize;
		Texture * m_buttonTexture;
		FMOD::Sound * m_buttonDownSound;
		SoundSystem * m_soundSystem;
		Config * m_config;
		SharedData(Config * config, SoundSystem * soundSystem);
		~SharedData();
		static SharedData * Instance(Config * config, SoundSystem * soundSystem);
		void Release();
		void PlaySound();
	} * sm_buttonData;
};

#endif	//	GUI__Button_h

